﻿#ifndef ALGWORKER_H
#define ALGWORKER_H
#include <QObject>
#include "vector"
#include <QTime>
#include "Common/common.h"
#include "Alg/algimpurity.h"

using namespace HalconCpp;

class AlgWorker : public QObject
{
    Q_OBJECT
public:
    explicit AlgWorker(QObject *parent = nullptr);
    ~AlgWorker();

    int m_nCountD1 = 0;
    int m_nCountD2 = 0;
    int m_nCountD3 = 0;
    bool m_bD2 = false;
    bool m_bD3 = false;

    int m_nIndex = 0;
    int m_nCount = 0;

    int m_nImplement = 0;



    int m_nNGorOK1[20];
    int m_nNGorOK2[20];
    int m_nNGorOK3[20];
    int m_nResult = 0;

    int m_nSResult = 0;
    int m_nOResult = 0;

    int m_nModel = 1; // 0 自动模式 1 手动模式 不计算数据
    HalconCpp::HTuple ModelID;


    HalconCpp::HTuple hvCCDHandle;
    // 存图
    SW_SaveImg m_swSaveImg;
    int m_nSave = 0;

    ALG_PLACE m_algPlace;
    int CCD_Alg(HalconCpp::HObject imgA, HalconCpp::HObject imgB, int ccdIndex);



    // 算法参数
    QList<HalconCpp::HObject> lImgAs;
    QList<HalconCpp::HObject> lImgBs;
    M_R_IMPURITY m_part;
    AlgImpurity m_algImpurity;

    void clearAllData();
signals:
    void sigCameraResult(int m_nResult);


    void sigSaveImgStart(CameraData m_cImageInfo);

    void sigFrameNum();
public slots :
    void Initialize();
    void start(CameraData m_cImageInfo);



public:
    void show(HalconCpp::HObject img, HalconCpp::HTuple hv_WindowHandle, int index);

    QString msg;
};

#endif // ALGWORKER_H
